<template>
	<view class="cake-item text-left f12" @click='toDetail' :data-id="gdata.id">
		<!-- 商品图 -->
		<image class="poster" :src="gdata.img"></image>
		<view class="info flex align-center justify-between">
			<view class="info-left flex direct-column justify-between">
				<!-- 商品名字 -->
				<view class="color-2c bold ellipsis" v-if="gdata.name">{{ gdata.name }}</view>
				<view class="french color-8d ellipsis" v-if="gdata.french">{{ gdata.french }}</view>
				<view class="price bold color-2c">
					<!-- 商品价格 -->
					<text>￥</text>
					{{ gdata.price }}
				</view>
			</view>
			<view class="info-right">
				<view class="label bgColor-ffe" v-if="gdata.tname">{{gdata.tname}}</view>
				<view class="cart-btn bgColor-ffe">
					<text class="iconfont icon-gouwuche color-8d"></text>
				</view>
			</view>
		</view>
		<view class="box" v-if="gdata.lowerShelf" @click.stop="handleBan">
			<text class="shouqin">已售罄</text>
		</view>
	</view>
</template>


<script>
	import {
		mapState
	} from 'vuex'
	export default {
		name: 'goods-item',
		props: ['gdata'],
		data() {
			return {
				list: [{
					type: 'success',
					message: "成功加入购物车",
					iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
				}],
			}
		},
		methods: {
			toDetail(e) {
        console.log(e,e.target.dataset.id);
        let id = e.target.dataset.id || e.currentTarget.dataset.id
        uni.navigateTo({
          url: `/pagesA/detail/detail?id=${id}`
        })
			},
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		background-color: #cfcac38c;
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 1;

		.shouqin {
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%) rotate(45deg);
			font-size: 28rpx;
			color: white;
			font-weight: bold;
		}
	}

	.cake-item {
		width: 350rpx;
		position: relative;

		.poster {
			height: 350rpx;
			width: 350rpx;
			background-color: #f5f5f5;
		}
	}

	.info {
		padding: 10rpx 0;

		.info-left {
			width: 220rpx;
			height: 100rpx;
		}

		.info-right {
			position: relative;
		}

		.cart-btn {
			width: 60rpx;
			height: 60rpx;
			border-radius: 50%;
			text-align: center;
			line-height: 60rpx;
			position: absolute;
			right: 0rpx;
			top: 40rpx;
		}
	}

	.label {
		line-height: 32rpx;
		padding: 0 8rpx;
		border-radius: 8rpx;
	}
</style>
